package com.minisoft.jd.seckill;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.mail.MailUtil;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author JueSu
 * @description: TODO
 * @date 2021/12/8 9:37
 */
public class MailSender {

    public static void sendLogin(String imageName,InputStream inputStream) {
        //如果是服务器，则发送邮件通知
        Map<String, InputStream> map = new HashMap<>();
        map.put("<qrcode>",inputStream);
        MailUtil.sendHtml(Killer.TO_EMAIL, "登录通知", StrUtil.format("<h2>请扫码登录：{}</h2><img src=\"cid:qrcode\"/>",imageName), map);
    }

    public static void sendMsgList(String subject,List<String> msgList) {
        StringBuilder html = new StringBuilder("<div>");
        msgList.forEach(item -> html.append("<div>").append(item).append("</div></br>"));
        html.append("</div>");
        MailUtil.sendHtml(Killer.TO_EMAIL, subject, html.toString());
    }
}
